﻿using System;
using ApiGateway;
using HttpApiGateway;
using HttpApiGateway.Model;
using RpcClient;
using RpcHelper.Validate;
using Wedonek.RpcStore.Gateway.Interface;
using Wedonek.RpcStore.Gateway.Model;
using Wedonek.RpcStore.Service.Model;

namespace Wedonek.RpcStore.Gateway.Controller
{
    /// <summary>
    /// 系统广播的错误日志
    /// </summary>
    internal class BroadcastLogController : ApiController
    {
        private readonly IBroadcastLogService _Service;

        public BroadcastLogController(IBroadcastLogService service)
        {
            this._Service = service;
        }
        /// <summary>
        /// 获取日志详细
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public BroadcastErrorLogData Get([NullValidate("rpc.broadcast.log.id.null")] Guid id)
        {
            return this._Service.Get(id);
        }
        /// <summary>
        /// 查询错误日志
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public PagingResult<BroadcastLog> Query(PagingParam<BroadcastQueryParam> param)
        {
            BroadcastLog[] logs = this._Service.Query(param.Param, param.ToBasicPaging(), out long count);
            return new PagingResult<BroadcastLog>(count, logs);
        }
    }
}
